      <div class="templatemo-content-wrapper">
        <div class="templatemo-content">
          <ol class="breadcrumb">
            <li><a href="<?=site_url()?>/order/index">订单管理</a></li>
            <li class="active">供货商订单</li>
          </ol>
          <div class="row">
            <div class="col-md-12">
             <!-- <div class="btn-group pull-right" id="templatemo_sort_btn">
                <button type="button" class="btn btn-default">Sort by</button>
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                  <span class="caret"></span>
                  <span class="sr-only">Toggle Dropdown</span>
                </button>
                <ul class="dropdown-menu" role="menu">
                  <li><a href="#">First Name</a></li>
                  <li><a href="#">Last Name</a></li>
                  <li><a href="#">Username</a></li>
                </ul>
             </div>-->
              <div>
              		<select id="ordertype">
            			<option value="1">按下单时间倒序排序</option>
            			<option value="2">按供货商排序</option>
            		</select>
              		<button class="btn btn-primary" id="submit_btn">搜索</button>
              </div>
              <div class="table-responsive">
                <h4 class="margin-bottom-15">供货商订单列表</h4>
                <table class="table table-striped table-hover table-bordered">
                  <thead>
                    <tr>
                      <th>ID</th>
                      <th>订单编号</th>
                      <th>供货商</th>
                      <th>用户</th>
                      <th>下单时间</th>
                      <th>支付方式</th>
                      <th>支付时间</th>
                      <th>收货时间</th>
                      <th>备注</th>
                      <th>状态</th>
                      <th>是否结算</th>
                      <th>操作</th>
                    </tr>
                  </thead>
                  <tbody>
                  	<?php foreach ($orders as $item):?>
                    <tr> 
                      <td><?php echo $item['id'];?></td>
                      <td><?php echo $item['orderno'];?></td>
                      <td><?php echo $item['sname'];?></td>
                      <td><?php echo $item['uname'];?></td>
                      <td><?php echo $item['order_time'];?></td>
                      <td><?php 
                      	if($item['payment_mode']==1){
                      		echo "支付宝支付";
                      	}
                      	if($item['payment_mode']==2){
                      		echo "微信支付";
                      	}
                      	if($item['payment_mode']==3){
                      		echo "货到付款";
                      	}
						if($item['payment_mode']==4){
                      		echo "余额支付";
                      	}
                      ?></td>
                     <td><?php echo $item['payment_time'];?></td>
                     <td><?php echo date("Y-m-d",strtotime($item['receive_time']));?></td>
                      <td><?php echo $item['note'];?></td>
                       <td><?php 
                        if($item['state'] == 0)
                        {
                        	echo "待支付";
                        }
						if($item['state'] == 1)
                        {
                        	echo "已支付";
                        }
						if($item['state'] == 2)
                        {
                        	echo "拣货中";
                        }
						if($item['state'] == 3)
                        {
                        	echo "配送中";
                        }
						if($item['state'] == 4)
                        {
                        	echo "订单完成";
                        }
                        ?></td>
                        <td>
                        	<?php
                        			if($item['settle'] == 0)
                        			{
                        				echo "未结算";
                       				 }
									if($item['settle'] == 1)
                        			{
                        				echo "已结算";
                        			}
                        	?>
                        </td>
                        <td>
                        <?php 
                        if($item['settle'] == 0 )
                        {
                        	echo '<a href="#" class="btn btn-link settle" data-id="'.$item['id'].'" >结算</a>';
						}
                        ?>	
                        <?php 
                        	echo '<a href="'.site_url('order/supplierorderdetail/id/'.$item['id']).'" class="btn btn-link detail">订单详情</a>'; 
                        ?>
                        </td>
                    </tr>
                     <?php endforeach;?>
                  </tbody>
                </table>
              </div>
               <?php  echo $links; ?>
              <!--<ul class="pagination pull-right">
                <li class="disabled"><a href="#">&laquo;</a></li>
                <li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">2 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">3 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">4 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">5 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">&raquo;</a></li>
              </ul>  -->
            </div>
          </div>
        </div>
      </div>
    <script>
	$(document).ready(function() {
		$("#submit_btn").click(function() {
			var ordertype = $("#ordertype").val();
			var url = "<?php echo site_url('order/supplierorderlist')?>";
			window.location.href=url+"/ordertype/"+ordertype;
		});
		$(".settle").click(function() {
			if(confirm("确定结算该订单吗？"))
			{
			var id = $(this).attr("data-id");
			$.ajax({
				url : '<?php echo site_url('order/update')?>',
				type : "post",
				async : true,
				data : {
					'id' : id,
					'settle':1
				},
				dataType : "json",
				timeout : "1000",
				error : function() {
					alert("服务加载出错");
				},
				success : function(data) {
					if(data.code)
					{
						alert(data.msg);
						window.location.reload();
					}else{
						alert(data.msg);
					}
				}
			});
			}
		});
	}); 
</script>